import request from '@/axios'
import type {
  AnalysisTotalTypes,
  UserAccessSource,
  WeeklyUserActivity,
  MonthlySales
} from './types'

export const getCountApi = (): Promise<IResponse<AnalysisTotalTypes[]>> => {
  return request.get({ url: '/mock/analysis/total' })
}

export const getUserAccessSourceApi = (): Promise<IResponse<UserAccessSource[]>> => {
  return request.get({ url: '/mock/analysis/userAccessSource' })
}

export const getWeeklyUserActivityApi = (): Promise<IResponse<WeeklyUserActivity[]>> => {
  return request.get({ url: '/mock/analysis/weeklyUserActivity' })
}

export const getMonthlySalesApi = (): Promise<IResponse<MonthlySales[]>> => {
  return request.get({ url: '/mock/analysis/monthlySales' })
}

// 新增统计分析接口
export const getStatistics = (): Promise<
  IResponse<{
    productCount: number
    orderCount: number
    userCount: number
    cartCount: number
    weeklySales: {
      year: number
      week: number
      salesAmount: number
    }[]
    monthlySales: {
      year: number
      month: number
      salesAmount: number
    }[]
  }>
> => {
  return request.get({ url: '/analysis/statistics' })
}
